/**
 * 富文本编辑器
 * @param options
 * @return
 * @usecase 
 * 	$('textarea[name="item.content"]',$.cssTab.focus()).richEditor({afterChange:function(){}});//加载
 * 	$('textarea[name="item.content"]',$.cssTab.focus()).data('editor').html(decodeURIComponent("<ww:property value='ff' default=""/>"||''));//赋值
 */
$.prototype.richEditor = function(options){
	var self = $(this);
	var _options = {
		resizeType : 1,
		allowPreviewEmoticons : false,
		allowImageUpload : false,
		items : [
			'source','code','|','fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline',
			'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',
			'insertunorderedlist', '|', 'emoticons', 'image', 'link', '|', 'preview', 'fullscreen']
	};
	if(KindEditor){
		//options: default
		if(!options){
			options = _options;
		}
		$.extend(true,options,_options);
		//options: content change
		if(self.is('input[type=hidden][name]') && options && !options.afterChange){
			options = options||{};
			options.afterChange = function(){
				var editor = this;
				var html = editor.html();
				self.val(encodeURI(html));
			}
		}
		//create
		var editor;
		editor = KindEditor.create(self,options);
		//editor codehtml
		editor.codeHtml = function(html){editor.html(decodeURIComponent(html)+"");}
		self.data('editor',editor);
		return editor;
	}
}